<style scoped lang="scss">
.viewimage {
  background: #ffffff;
  height: 100%;
  width: 100%;
  color: grey;
  position: relative;
}
.chosekuang {
  width: 100%;
  height: 100%;
  min-width: 50px;
  min-height: 50px;
  border: dotted 1px grey;
  border-radius: 10px;
}
.imgyulan {
  min-width: 50px;
  height: auto;
  border-radius: 10px;
}
</style>
<style lang="scss">
.cropperdialog .el-dialog__body {
  padding: 0 !important;
}
.viewimage {
  .el-dialog__headerbtn {
    font-size: 30px !important;
  }
}
</style>
<template>
  <div class="viewimage">
    <div class="chosekuang fxrow fxcc" @click="dialogVisible=true">
      <img :src="imagesrc" class="imgyulan" :style="{width:imgwidth,height:imgheight}">
    </div>
    <el-dialog :visible.sync="dialogVisible" width="80%" @opened="dialogOpened" @closed="dialogClosed" custom-class="cropperdialog" :close-on-click-modal="false">
      <div class="fxrow fxcc" style="padding: 0 10%;">
        <img :src="imagesrc" alt="" style="width:auto;height:auto;max-width:80%;max-height:80%;">
      </div>
      <span slot="footer" class="dialog-footer fxcc" style="margin-top:30px;">
        <el-button @click="cancelDialog" type="primary" plain size="medium">取 消</el-button>
      </span>
    </el-dialog>
  </div>
</template>

<script>
require("assets/scss/cropper.min.css");
import { VueCropper } from "vue-cropper";
export default {
  data: function() {
    return {
      imagesrc: "",
      dialogVisible: false,
      imgwidth: "",
      imgheight: ""
    };
  },
  props: {
    src: "",
    width: "",
    height: ""
  },
  mounted() {
    this.init();
  },
  methods: {
    init() {
      this.imagesrc = this.src;
      this.imgwidth = !!this.width ? this.width : "100%";
      this.imgheight = !!this.height ? this.height : "auto";
    },
    dialogOpened() {},
    dialogClosed() {},
    cancelDialog() {
      this.dialogVisible = false;
    }
  }
};
</script>
